
/*初始化球体*/
var viewer = new Cesium.Viewer('cesiumContainer',{
                                                                            //暂不加入地形
    imageryProvider : new Cesium.MapboxStyleImageryProvider({
        url:'https://api.mapbox.com/styles/v1/',
        username:'jimbozhu',
        styleId:'ckifov1l14szq19pm3wjogvao',
        accessToken: 'pk.eyJ1IjoiamltYm96aHUiLCJhIjoiY2sxMXNkbzFmMGszOTNocDJmbWdpcndiNSJ9.R-M1MZCR6kKj8MCEPbrDEA',
        credit:'MapBox',
        rectangle: new Cesium.Rectangle.fromDegrees (111,21,120,23),	    //切图范围
    }),
    infoBox:false,                                                          //自带信息框隐藏
    selectionIndicator:false                                                //自带选中效果框隐藏
});

var scene = viewer.scene;

/*切片缓存加载*/

var promise = scene.open(url_SZBuilding);
var promise_2 = scene.open(url_QHBoundary);

Cesium.when.all([promise,promise_2], function(layers){

    scene.camera.flyTo({                                              //页面开启初视角
        destination:{
            "x": -2383226.965984025,
            "y": 5394137.3843374085,
            "z": 2437720.8301236867
          },
        orientation:{
            heading:0.40169408217282054,
            pitch:-0.4416870707716809,
            roll:6.281747613758331
        },
        duration:1
    });
                                                                        //调整样式
    var layer = scene.layers.find("片区划分_150m");        //前海边线
    var layer_2 = scene.layers.find("LinearExtrudeResult@test_2");          //深圳建筑
    
    layer.style3D.fillForeColor = new Cesium.Color(6/255,171/255,201/255,0.3);
    var hyp = new Cesium.HypsometricSetting();
    setHypsometric(layer);			
    function setHypsometric(layer) {
        hyp.emissionTextureUrl = "images/线状扫描纹理2.png";		     //参数 自发光纹理图
        hyp.emissionTexCoordVSpeed = -0.2;		                        //参数 泛光下降（上升）速度
        layer.hypsometricSetting = {
            hypsometricSetting: hyp,
        }
    };
    layer.setOnlyObjsVisible([], true);

    layer_2._residentRootTile = true;		
    layer_2.style3D.fillForeColor = new Cesium.Color(0.0,0.0,0.1,0.3);	
    layer_2.selectEnabled = false;

});

var QHBuildingLayers=[];
var selected_buildings=[];

var promise_3 = viewer.scene.open(url_QHBuilding);                          //前海建筑
var promise_4 = viewer.scene.open(url_QHUnit);                              //前海开发单元
Cesium.when.all([promise_3,promise_4], function(layers){
    QHBuildingLayers = layers[0]
    for(i=0;i<QHBuildingLayers.length;i++){
        QHBuildingLayers[i].selectEnabled = false;
        QHBuildingLayers[i]._residentRootTile = true;
    }
    var layer_4 = scene.layers.find("version3");
    layer_4.style3D.fillForeColor = new Cesium.Color(0,216/255,1,0.2);
    layer_4.setOnlyObjsVisible([], true);
})